import dash
import feffery_antd_components as fac
from dash import html
from dash.dependencies import Input, Output

from server import app

layout = html.Div(
    [
        fac.AntdSpace(
            [
                fac.AntdButton(
                    '按钮1',
                    id='tab2-demo-button1'
                ),
                fac.AntdButton(
                    '按钮2',
                    id='tab2-demo-button2'
                ),
                fac.AntdButton(
                    '按钮3',
                    id='tab2-demo-button3'
                )
            ]
        ),
        fac.AntdDivider(isDashed=True),
        html.Pre(
            id='demo2-output'
        )
    ]
)


@app.callback(
    Output('demo2-output', 'children'),
    [Input('tab2-demo-button1', 'nClicks'),
     Input('tab2-demo-button2', 'nClicks'),
     Input('tab2-demo-button3', 'nClicks')]
)
def tab2_callback_demo(nClicks1, nClicks2, nClicks3):
    if dash.callback_context.triggered[0]['prop_id'] == '.':
        return dash.no_update

    return '本次回调由 {} 触发'.format(dash.callback_context.triggered[0]['prop_id'])
